Skip to content

[Sema] Downgrade noasync diagnostic to warning for closure macro args #80853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 18, 2025

Conversation

hamishknight
Copy link
Contributor

@hamishknight hamishknight commented Apr 16, 2025

Downgrade to a warning until the next language mode. This is necessary since we previously missed coercing macro arguments to parameter types, resulting in cases where closure arguments weren't being treated as async when they should have been. This then allows us to reapply #80583.

rdar://149328745
Resolves #80835

@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight
Copy link
Contributor Author

@swift-ci please test source compatibility

// argument until the next language mode.
auto shouldWarnUntilFutureVersion = [&]() {
auto *CE = dyn_cast<ClosureExpr>(noAsyncDC);
return CE && CE->isMacroArgument();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was originally hoping we could use namelookup::isInMacroArgument here, but we don't currently track macro expansion expressions in the ASTScope tree and it didn't really seem worth it for this change.

Previously we would avoid rewriting the arguments in CSApply, but
that can result in incorrect behavior in MiscDiagnostics passes, e.g
incorrectly treating all closure arguments as escaping. Make sure
we rewrite the arguments as we would in regular type-checking.

rdar://148665502
Introduce `Version::getFutureMajorLanguageVersion` to make it easier
to find clients that will need to be updated once we have a new
language mode.
Downgrade to a warning until the next language mode. This is
necessary since we previously missed coercing macro arguments to
parameter types, resulting in cases where closure arguments weren't
being treated as `async` when they should have been.

rdar://149328745
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit 3c30234 into swiftlang:main Apr 18, 2025
5 checks passed
@hamishknight hamishknight deleted the macro-async-warning branch April 18, 2025 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Downgrade diagnostic for uses of noasync declarations in async contexts in macro arguments
3 participants